<?php

  // echo $mp4;exit();

  // exec ("ffmpeg -i ".$mp4." -y -f image2 -ss 1  ./images/".date(Ymd)."/".$img);
   
   function getVideoInfo($file) {
  
	  $command = sprintf(FFMPEG_PATH, $file);
	  
	  ob_start();
	  passthru($command);
	  $info = ob_get_contents();
	  ob_end_clean();
	  
	  $data = array();
	  if (preg_match("/Duration: (.*?), start: (.*?), bitrate: (\d*) kb\/s/", $info, $match)) {
		$data['duration'] = $match[1]; //播放时间
		$arr_duration = explode(':', $match[1]);
		$data['seconds'] = $arr_duration[0] * 3600 + $arr_duration[1] * 60 + $arr_duration[2]; //转换播放时间为秒数
	   
	  }
	  
	  //$data['size'] = filesize($file); //文件大小
	  return $data;
	}
    define('FFMPEG_PATH', 'ffmpeg -i "%s" 2>&1');
//用法
	$videoinfo = getVideoInfo($mp4);
		
   // return $videoinfo;